import { ArrayTypeAdapter } from '../adapter/ArrayTypeAdapter';
import { ITypeAdapter } from '../adapter/ITypeAdapter';
import { ObjectTypeAdapter } from '../adapter/ObjectTypeAdapter';
import { DefaultTypeAdapter } from '../adapter/DefaultTypeAdapter';
import { ITypeAdapterFactory } from './ITypeAdapterFactory';
import ArrayList from '@ohos.util.ArrayList';
import { ArrayListTypeAdapter } from '../adapter/ArrayListTypeAdapter';
import List from '@ohos.util.List';
import { ListTypeAdapter } from '../adapter/ListTypeAdapter';
import { MapTypeAdapter } from '../adapter/MapTypeAdapter';

export class TypeAdapterFactory implements ITypeAdapterFactory {
  create(targetValue: any): ITypeAdapter {
    if (targetValue instanceof Map) {
      return new MapTypeAdapter()
    } else if (targetValue instanceof List) {
      return new ListTypeAdapter()
    } else if (targetValue instanceof ArrayList) {
      return new ArrayListTypeAdapter()
    } else if (targetValue instanceof Array) {
      return new ArrayTypeAdapter()
    } else if (targetValue instanceof Object) {
      return new ObjectTypeAdapter()
    } else {
      return new DefaultTypeAdapter()
    }
  }
}